package com.tyf.bookreader;

import com.tyf.bookreader.dto.BookInfoDto;
import com.tyf.bookreader.dto.ChapterDto;
import com.tyf.bookreader.dto.ContentDto;
import com.tyf.bookreader.dto.LastChapterInfoDto;
import com.tyf.bookreader.service.BookService;
import com.tyf.bookreader.component.Result;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @Description TODO
 * @Author shallow
 * @Date 2023/4/2 10:37
 */

@SpringBootTest(classes = BookReaderApplication.class)
public class testBook {
    @Autowired
    private BookService bookService;

    @Test
    public void testCategoryList(){
        bookService.listCategory().getData().forEach(v->{
            System.out.println("v = " + v);
        });
    }

    @Test
    public void testGetBookById(){
        BookInfoDto data = bookService.getBookById(1011L).getData();
        System.out.println("data = " + data);

    }

    @Test
    public void testAddVisitCount(){
        bookService.addVisitCount(1011L);
    }

    @Test
    public void testGetLastChapterAbout(){
        LastChapterInfoDto data = bookService.getLastChapterAbout(1011L).getData();
        System.out.println("data = " + data);
    }

    @Test
    public void testListRecBooks() throws NoSuchAlgorithmException {
        List<BookInfoDto> data = bookService.listRecBooks(1011L).getData();
        System.out.println("data = " + data);
    }

    @Test
    public void testListChapters(){
        for (ChapterDto datum : bookService.listChapters(1011L).getData()) {
            System.out.println("datum = " + datum);
        }

    }

    @Test
    public void testGetContentByChapterId(){
        Result<ContentDto> contentByChapterId = bookService.getContentByChapterId(1L);
        System.out.println("contentByChapterId = " + contentByChapterId);
    }

    @Test
    public void testGetPreChapterId(){
        bookService.getPreChapterId(1L);
    }

}
